package controlLayer;
import modelLayer.PersonContainer;
import modelLayer.Person;

/**
 * PersonCtr is a class that connects the Person interface with the Person domaine class.
 * 
 * @author group 6 - Stefan Patatu, Stan Cosmin Madalin, Monika Vysniauskaitė, Larowski Michal, Njogu Alex, Cristian Moldovan
 */
public class PersonCtr {
    private PersonContainer personContainer;
    
    /**
     * Get the PersonContaner instance
     */
    public PersonCtr() {
        personContainer = PersonContainer.getInstance();
    }
    
    /**
     * Create a Person object by a given name, address, postalCode, city, phone.
     * @param name The name of the person.
     * @param address The address of the person.
     * @param postalCode The postal code of the person.
     * @param city The city of the person.
     * @param phone The phone number of the person.
     */
    public void createPerson(String name, String address, String postalCode, String city, String phone) {
        Person p = new Person(name, address, postalCode, city, phone);
        personContainer.addPerson(p);
    }
    
    /**
     * Update the Person object information such as name, address, postal code, city, phone.
     * @param ID the ID of the soon to be updated Person object
     * @param name The name of the person.
     * @param address The address of the person.
     * @param postalCode The postal code of the person.
     * @param city The city of the person.
     * @param phone The phone number of the person.
     */
    public void updatePerson(int ID, String name, String address, String postalCode, String city, String phone) {
        personContainer.updatePerson(ID, name, address, postalCode, city, phone);
    }

    /**
     * Get a Person object by a given ID.
     * @param ID The ID of a person.
     */
    public Person getPerson(int ID) {
        return personContainer.getPerson(ID);
    }
    
    /**
     * Delete a Person object from the people ArryList
     * @param ID The ID of the Person object to be deleted.
     */
    public void deletePerson(int ID) {
        personContainer.deletePerson(ID);
    }
}
